#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    vector<string> in;
    string tmp;
    while (cin >> tmp && tmp != "0") in.push_back(tmp);
    for (auto it= in.end()-1; it != in.begin(); --it)
        cout << *it << " ";
    cout << *in.begin();
    return 0;
}
